import React, { useState, useRef, useMemo, useCallback } from "react";
import Home from "./pages/Home";
export default function App() {
  // let [count, setCount] = useState(1);
  // let inputRef = useRef();
  // const clickHandler = () => {
  //   inputRef.current.focus();
  // };
  let [count, setCount] = useState(1);
  const clickHandler = () => {
    setCount(++count);
  };

  // const handler = () => {
  //   console.log("1111");
  // };
  // 使用useMemo缓存函数
  // const handler = useMemo(() => {
  // return () => {
  //   console.log("1111");
  // };
  // }, []);
  // 使用useCallback缓存函数
  const handler = useCallback(() => {
    console.log("1111");
  }, []);
  return (
    <div>
      <h2>App</h2>
      <h2>{count}</h2>
      <button onClick={clickHandler}>++</button>
      <hr />
      <Home handler={handler}></Home>
      {/* <input type="text" ref={inputRef} />
      <button onClick={clickHandler}>获取焦点</button> */}
    </div>
  );
}
